﻿using BLL;
using Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using Tools;
using YunProject.Controllers.Base;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using log4net;
using System.Security.AccessControl;

namespace WebProject.Controllers
{
    public class AppController : BaseController
    {
        AppBLL appBLL;
        ServiceBLL serviceBLL;
        InventoryBLL inventoryBLL;
        ReturnResult rsl;
        WareHouseBLL wareBLL;
        ILog _log;
        ProCheckBLL checkBLL;

        public AppController()
        {
            appBLL = new AppBLL();
            serviceBLL = new ServiceBLL();//出入库方法
            //日志记录
            wareBLL = new WareHouseBLL();
            _log = LogManager.GetLogger(this.GetType().Name);
            checkBLL = new ProCheckBLL();
        }
        //
        // GET: /App/
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 修改移动端的服务器Ip地址
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult UpdateConnect()
        {
            #region 修改移动端的服务器Ip地址
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Message = "无法获取传递参数"; return Json(rsl);
            }
            else
            {
                json = Encryption.DesDecrypt(json);
                var jsonOb = JsonConvert.DeserializeObject<JObject>(json);
                if (jsonOb.Property("serviceIP") != null)
                {
                    if (!string.IsNullOrWhiteSpace(jsonOb["serviceIP"].ToString()))
                    {
                        rsl.Result = true;
                        rsl.Message = "连接成功";
                    }
                }
            }
            #region 加密方法
            string getdatas = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));//加密
            #endregion
            return Json(getdatas);
            #endregion
        }


        /// <summary>
        /// 获得账套号
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult get_Acount()
        {
            #region 获取账套
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Message = "无法获取传递参数"; return Json(rsl);
            }
            else
            {
                rsl = appBLL.getAccount(json);
            }
            #region 加密方法
            string getdatas = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));//加密
            #endregion
            return Json(getdatas);
            #endregion
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult Login()
        {
            #region 用户登录
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Message = "无法获取传递参数"; return Json(rsl);
            }
            else
            {
                rsl = appBLL.login(json);
            }
            #region 加密方法
            string getdatas = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));//加密
            #endregion
            return Json(getdatas);
            #endregion
        }

        /// <summary>
        /// 获取所有功能菜单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetMenuList()
        {
            rsl = new ReturnResult();
            #region 获取所有菜单
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                string getJson = Encryption.DesDecrypt(json);
                _log.Info("调用接口GetMenuList，入参参数:" + getJson);
                rsl = appBLL.GetMenuList(getJson);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult UpdateUserPassword()
        {
            rsl = new ReturnResult();
            #region 修改用户密码
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            //
            rsl = serviceBLL.updateUserPassword(json);
            _log.Info("UpdateUserPassword()方法：" + JsonConvert.SerializeObject(rsl));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }


        /// <summary>
        /// 获取出入库默认仓库信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetInOutWareStyle()
        {
            #region 获取仓库类别
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getInOutWareStyle(json);
            _log.Info("GetInOutWareStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取仓库信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetWareHouse()
        {
            #region 获取仓库信息
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);

            var json = streamReader.ReadToEndAsync().Result;
            var getDatas = Encryption.DesDecrypt(json);
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getWareHouse(json);
            _log.Info("GetWareHouse()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取出入库默认部门信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetInOutDeptStyle()
        {
            #region 获取部门类别
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getInOutDeptStyle(json);
            _log.Info("getInOutDeptStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取部门信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetDepartment()
        {
            #region 获取部门信息
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getDepartment(json);
            _log.Info("GetDepartment()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取收发类别与出入库类型的对应关系信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetInOutRdStyle()
        {
            #region 获取收发类别
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getInOutRdStyle(json);
            _log.Info("GetInOutRdStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取收发类别信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetRdStyle()
        {
            #region 获取收发类别
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getRdStyle(json);
            _log.Info("GetRdStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取版辊出入库类型与出入库类型的对应关系信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult getbgIoStyle()
        {
            #region 获取版辊出入库类型
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getbgIoStyle(json);
            _log.Info("getbgIoStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }


        /// <summary>
        /// 获取版辊出入库类型信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetbgIoType()
        {
            #region 获取版辊出入库类型
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.GetbgIoType(json);
            _log.Info("GetbgIoType()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取临时表中扫描单号
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetTempCode()
        {
            rsl = new ReturnResult();
            #region 获取临时表中扫描单号
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            //有重复的条码时默认是删除临时表中的该数据
            rsl = appBLL.getTempCode(json);
            _log.Info("GetTempCode()方法：" + rsl.Message);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取未完成的生产计划信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetPlanList()
        {
            #region 获取生产计划
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.GetPlanList(json);
            _log.Info("GetPlanList()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取生成的扫描编码
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetScanCode()
        {
            rsl = new ReturnResult();
            #region 获取生成的扫描编码
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getScanCode(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 保存出入库扫描的条码数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddScanRecord()
        {
            rsl = new ReturnResult();
            #region 保存扫描单号
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.addScanRecord(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取刚扫描数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetScanBarCode()
        {
            rsl = new ReturnResult();
            #region 获取扫描数据
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            json = Encryption.DesDecrypt(json);
            rsl = serviceBLL.getScanBarCode(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 删除扫描数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult DeleteScanBarCode()
        {
            rsl = new ReturnResult();
            #region 删除扫描数据
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result ;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            json = Encryption.DesDecrypt(json);
            //有重复的条码时默认是删除临时表中的该数据
            rsl = serviceBLL.DelCollectRepeat(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取出入库单号中所有条码的数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetInputList()
        {
            rsl = new ReturnResult();
            #region 获取出入库单号中所有条码
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            //
            rsl = appBLL.getInputList(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 保存扫描的临时单据数据（出入库）
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult SaveTmpeCode()
        {
            #region 保存临时数据
            rsl = new ReturnResult();
            serviceBLL = new ServiceBLL();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Message = "无法获取传递参数"; return Json(rsl);
            }
            else
            {
                _log.Info("接口(SaveTmpeCode)参数："+json);
                json = Encryption.DesDecrypt(json);
                rsl = serviceBLL.MSaveTempData(json);
            }
            #region 加密方法
            string getdatas = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));//加密        
            #endregion
            return Json(getdatas);
            #endregion
        }

        /// <summary>
        /// 删除出入库某个临时编码的所有数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult DeleteScanRecord()
        {
            rsl = new ReturnResult();
            #region 删除出入库某个临时编码的所有数据
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.deleteScanRecord(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取U8发货单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetSaleOrderList()
        {
            #region 获取U8销售订单
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getSaleOrderList(json);
            _log.Info("GetSaleOrderList()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 统计发货单明细对应的扫描相应条码的数量
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetTemScanSaleOrderList()
        {
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getTemScanSaleOrderList(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
        }



        /// <summary>
        /// 获取系统字典表中字段数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetDictionaryInfo()
        {
            rsl = new ReturnResult();
            #region 获取系统字典表中字段数据
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                string getJson = Encryption.DesDecrypt(json);
                _log.Info("调用接口GetDictionaryInfo，入参参数:" + getJson);
                rsl = appBLL.getDictionaryInfo(getJson);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }


        /// <summary>
        /// 获取未处理任务数量
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetNTaskConfirmNum()
        {
            rsl = new ReturnResult();
            Stream stream = Request.Body;
            StreamReader streamReader = new StreamReader(stream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                rsl = serviceBLL.getNTaskConfirmNum(json);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
        }

        /// <summary>
        /// 获取任务中心列表数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetTaskInfo()
        {
            rsl = new ReturnResult();
            Stream stream = Request.Body;
            StreamReader streamReader = new StreamReader(stream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                rsl = serviceBLL.getTaskInfo(json);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
        }

        /// <summary>
        /// 处理任务中心的任务方法
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult TaskConfirm()
        {
            rsl = new ReturnResult();
            Stream stream = Request.Body;
            StreamReader streamReader = new StreamReader(stream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                json = Encryption.DesDecrypt(json);
                rsl = serviceBLL.taskConfirm(json);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
        }


        /// <summary>
        /// 获取盘点任务信息列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetCheckTaskList()
        {
            rsl = new ReturnResult();
            #region 获取盘点任务信息列表
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                rsl = appBLL.getCheckTaskList(json);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 保存盘点扫描数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddInventoryRecord()
        {
            rsl = new ReturnResult();
            #region 保存扫描单号
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            json = Encryption.DesDecrypt(json);
            rsl = checkBLL.AddTaskRecord(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取盘点扫描数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetInventoryList()
        {
            rsl = new ReturnResult();
            inventoryBLL = new InventoryBLL();
            #region 获取盘点扫描数据
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            json = Encryption.DesDecrypt(json);
            rsl = checkBLL.getInventoryList(json);
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        /// <summary>
        /// 获取盘点报告信息列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetCheckTaskReportList()
        {
            rsl = new ReturnResult();
            #region 获取盘点报告信息列表
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            else
            {
                rsl = appBLL.getCheckTaskReportList(json);
            }
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }


        /// <summary>
        /// 检测系统版本是否更新
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult UpdateEditionApp()
        {
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.updateEditionApp(json);
            return Json(rsl);
        }

        /// <summary>
        /// 主辅料占用查询
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult MatSubOccuQuery()
        {
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.MatSubOccuQuery(json);

            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            return Json(getData);
        }

        /// <summary>
        /// 未调拨到车间库的占用原料查询
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult needTransVouchBar()
        {
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.needTransVouchBar(json);

            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            return Json(getData);
        }

        /// <summary>
        /// 获取u8业务员信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult getPersonInfo()
        {
            #region 获取人员信息
            rsl = new ReturnResult();
            Stream reqStream = Request.Body;
            StreamReader streamReader = new StreamReader(reqStream);
            var json = streamReader.ReadToEndAsync().Result;
            if (string.IsNullOrWhiteSpace(json))
            {
                rsl.Result = false;
                rsl.Message = "无法获取传递参数";
                return Json(rsl);
            }
            rsl = appBLL.getPersonInfo(json);
            _log.Info("getPersonInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
            #region 加密
            string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
            #endregion
            return Json(getData);
            #endregion
        }

        
        #region 移动端系统基础数据



        ///// <summary>
        ///// 获取token
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetToken()
        //{
        //    #region 获取token
        //    rsl = new ReturnResult();
        //    sysBLL = new SystemBLL();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Message = "无法获取传递参数"; return Json(rsl);
        //    }
        //    else
        //    {
        //        rsl = appBLL.getToken(json);

        //    }
        //    #region 加密方法
        //    string getdatas = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));//加密        
        //    #endregion
        //    return Json(getdatas);
        //    #endregion
        //}


        ///// <summary>
        ///// 获取存货信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetInventory()
        //{
        //    #region 获取存货信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getInventory(json);
        //    _log.Info("GetInventory()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}




        ///// <summary>
        ///// 获取用户移动端权限信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetUserPowerList()
        //{
        //    rsl = new ReturnResult();
        //    #region 获取用户移动端权限信息
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    else
        //    {
        //        string getJson = Encryption.DesDecrypt(json);
        //        _log.Info("调用接口GetUserPowerList，入参参数:" + getJson);
        //        rsl = appBLL.getUserPowerList(getJson);
        //    }
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取所有菜单
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetMenuTypeList()
        //{
        //    rsl = new ReturnResult();
        //    #region 获取所有菜单
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    else
        //    {
        //        string getJson = Encryption.DesDecrypt(json);
        //        _log.Info("调用接口GetMenuTypeList，入参参数:" + getJson);
        //        rsl = appBLL.getMenuTypeList(getJson);
        //    }
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取班组人员信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetAssistantInfo()
        //{
        //    #region 获取班组人员信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getAssistantInfo(json);
        //    _log.Info("GetAssistantInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}


        ///// <summary>
        ///// 获取盘点单号信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetInventoryCode()
        //{
        //    #region 获取盘点单号信息
        //    inventoryBLL = new InventoryBLL();
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = inventoryBLL.VenTaskInfo();
        //    _log.Info("GetRdStyle()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取客户信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetCustomer()
        //{
        //    #region 获取客户信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getCustomer(json);
        //    _log.Info("GetCustomer()方法："+JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取货位信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetGoodsPosition()
        //{
        //    #region 获取货位信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    json = Encryption.DesDecrypt(json);//解密
        //    rsl = appBLL.GetWareHousePosition(json);
        //    _log.Info("GetGoodsPosition()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取公共基础数据
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetCommonDataInfo()
        //{
        //    #region 获取公共基础数据
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getCommonDataInfo(json);
        //    _log.Info("GetCommonDataInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取生产子工序数据
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetGXInfo()
        //{
        //    #region 获取工序班组数据
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getGXInfo(json);
        //    _log.Info("GetGXInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取生产工序班组数据
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetGXGroupInfo()
        //{
        //    #region 获取工序班组数据
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getGXGroupInfo(json);
        //    _log.Info("GetGXGroupInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取U8发货单
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetSaleOrderList()
        //{
        //    #region 获取U8销售订单
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getSaleOrderList(json);
        //    _log.Info("GetSaleOrderList()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取U8发货退货单信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetDispatchList()
        //{
        //    #region 获取U8发货退货单信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getDispatchList(json);
        //    _log.Info("GetDispatchList()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取U8借出归回单信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetBorrowOutBackList()
        //{
        //    #region 获取U8发货退货单信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getBorrowOutBackList(json);
        //    _log.Info("GetBorrowOutBackList()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取U8借出借用单信息
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetBorrowOutList()
        //{
        //    #region 获取U8发货退货单信息
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getBorrowOutList(json);
        //    _log.Info("GetBorrowOutList()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        ///// <summary>
        ///// 获取U8生产计划单GetAllotRecordsInfo
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetProductPlan()
        //{
        //    #region 获取U8生产计划单
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    //rsl = appBLL.getProductPlan(json);
        //    rsl = appBLL.getPlanData(json);
        //    _log.Info("GetProductPlan()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}

        ///// <summary>
        ///// 获取U8调拨申请单
        ///// </summary>
        ///// <returns></returns>
        //[HttpPost]
        //public JsonResult GetAllotRecordsInfo()
        //{
        //    #region 获取U8生产计划单
        //    rsl = new ReturnResult();
        //    Stream reqStream = Request.InputStream;
        //    StreamReader streamReader = new StreamReader(reqStream);
        //    var json = streamReader.ReadToEnd();
        //    if (string.IsNullOrWhiteSpace(json))
        //    {
        //        rsl.Result = false;
        //        rsl.Message = "无法获取传递参数";
        //        return Json(rsl);
        //    }
        //    rsl = appBLL.getAllotRecordsInfo(json);
        //    _log.Info("GetAllotRecordsInfo()方法：" + JsonConvert.SerializeObject(rsl.Data));
        //    #region 加密
        //    string getData = Encryption.DesEncrypt(JsonConvert.SerializeObject(rsl));
        //    #endregion
        //    return Json(getData);
        //    #endregion
        //}
        #endregion



    }
}